<?php

/**
 * XHTML_Col, xhtml_lib
 * 
 * This file contains the source code for the XHTML_Col class.
 * @author Fernando Jimenez Mocobono <fjmcool@gmail.com>
 * @version 0.1
 * @package xhtml_lib
 */

include_once "XHTML_Table_Common_Element.php";
include_once "XHTML__Col_Element.php";

/**
 * The XHTML_Col class is a handler for the col xhtml-strict tag as a part 
 * of a xhtml-strict php-handler implementation.
 */
class XHTML_Col extends XHTML_Table_Common_Element 
	implements XHTML__Col_Element {
    
    // inner elements
        
    /**
     * Defines the number of columns the <col> should span.
     * 
     * @var integer
     */
    protected $span = 1;
    
    /**
     * Defines the width of the column.
     * Note: Overrides the width set in <colgroup>.
     *
     * @var number
     */
    protected $width;
    
    // Methods
    
    /**
     * Constructs a XHTML_Col object.
     */
    function __construct()
    {
    	parent::__construct();
    }
    
	/**
     * Sets the number of columns the <colgroup> should span.
     * 
     * @param integer $span
     */
    function setSpan($span)
    {
    	$this->span = $span;
    }
    
    
    /**
     * Gets the number of columns the <colgroup> should span.
     * 
     * @return integer
     */
    function getSpan()
    {
    	return $this->span;
    }
    
    /**
     * Sets the width of the column.
     * Note: Overrides the width set in <colgroup>.
     *
     * @param number $width
     */
    function setWidth($width)
    {
    	$this->width = $width;
    }
    
    /**
     * Gets the width of the column.
     * Note: Overrides the width set in <colgroup>.
     *
     * @return number
     */
    function getWidth()
    {
    	return $this->witdh;
    }
 
    // Overriding the toString method for a proper implementation.
    
    /**
    * Returns the string representation for echoing the class atributes.
    *
    * @return string
    */
    function toString()
    {
    	$auxString = "<col".parent::toString();
    
    	if (isset($this->span)) {
    		$auxString = $auxString."span=\"".$this->span."\" ";
    	}
    	
    	if (isset($this->width)) {
    		$auxString = $auxString."witdh=\"".$this->width."\" ";
    	}
    	
    	$auxString = $auxString."/>\n";
                
        return $auxString;
    }
    
}